<?php

class myUser extends sfBasicSecurityUser
{

    /**
     * Returns the user propel object
     *
     * @return User
     */
    public function getObject()
    {
        return UserPeer::retrieveByPK($this->getAttribute('user_id'));
    }

    /**
     * Returns the current user id
     *
     * @return int
     */
    public function getId()
    {
        return $this->getAttribute('user_id');
    }

    /**
     * Sets the current user id
     *
     * @param int $id
     * @return myUser
     */
    public function setId($id)
    {
        $this->setAttribute('user_id', $id);

        return $this;
    }

    public function setAuthenticated($user_id)
    {
        if ($user_id)
        {
            parent::setAuthenticated(true);
            $this->setId($user_id);
        }
        else
        {
            parent::setAuthenticated(false);
            $this->setId(null);
        }

        return $this;
    }

    public function setGlobal($name, $value)
    {
        return $this->setFlash('global/' . $name, $value, false);
    }

    public function getGlobal($name, $default = null)
    {
        return $this->getFlash('global/' . $name, $default);
    }


}
